﻿using RuoVea.ExSugar.Attributes;
using RuoVea.ExSugar.Entity;
using SqlSugar;
using System.ComponentModel;

namespace RuoVea.OmiApi.Article.Entitys;

/// <summary>
/// 文章评论表
/// </summary>
[SugarTable(nameof(ArtComment), TableDescription = "文章评论表")]
[Description("文章评论表")]
[SugarIndex($"IX_{nameof(ArtComment)}_{nameof(ArticleId)}", nameof(ArticleId), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(ArtComment)}_{nameof(PId)}", nameof(PId), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(ArtComment)}_{nameof(UserId)}", nameof(UserId), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(ArtComment)}_{nameof(Status)}", nameof(Status), OrderByType.Asc)]
[SugarIndex($"IX_{nameof(ArtComment)}_{nameof(CreateTime)}", nameof(CreateTime), OrderByType.Desc)]
public class ArtComment : EntityBase
{
    /// <summary>
    /// 父评论Id，0表示一级评论
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(PId), columnDescription :"父评论Id，0表示一级评论", DefaultValue = "0")]
    public long PId { get; set; } = 0;

    /// <summary>
    /// 文章ID
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(ArticleId), columnDescription :"文章ID")]
    public long ArticleId { get; set; }

    /// <summary>
    /// 评论用户ID
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(UserId), columnDescription :"评论用户ID")]
    public long UserId { get; set; }

    /// <summary>
    /// 评论内容
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(Content), columnDescription :"评论内容", ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string Content { get; set; }

    /// <summary>
    /// 点赞数
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(LikeCount), columnDescription :"点赞数", DefaultValue = "0")]
    public long? LikeCount { get; set; } = 0;

    /// <summary>
    /// 状态：0-待审核，1-已发布，2-已删除
    /// </summary>
    [ConfigSugarColumn(columnKey:  nameof(Status), columnDescription :"状态：0-待审核，1-已发布，2-已删除", DefaultValue = "0")]
    public int? Status { get; set; } = 0;

    /// <summary>
    /// 导航属性 - 父评论（多对一）
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(PId))]
    [SugarColumn(IsIgnore = true)]
    public ArtComment ParentComment { get; set; }

    /// <summary>
    /// 导航属性 - 子评论列表（一对多）
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(ArtComment.PId))]
    [SugarColumn(IsIgnore = true)]
    public List<ArtComment> Children { get; set; }

    /// <summary>
    /// 导航属性 - 文章（多对一）
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(ArticleId))]
    [SugarColumn(IsIgnore = true)]
    public ArtArticle Article { get; set; }
}
